package com.brtbeacon.demo.lot.fragment;

import android.content.Context;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.brtbeacon.demo.lot.state.ParkingState;

public class ParkingBaseFragment extends Fragment {

    protected ParkingState state;

    public ParkingBaseFragment() {

    }

    public ParkingState getState() {
        return state;
    }

    public void setState(ParkingState state) {
        this.state = state;
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        if (state != null) {
            state.onFragmentAttach(context, this);
        }
    }

    @Override
    public void onDetach() {
        if (state != null) {
            state.onFragmentDetach(this);
        }
        super.onDetach();
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        if (state != null) {
            state.onFragmentViewCreated(this, view);
        }
    }
}
